<div>
  <yu-panel title="批量重跑方案管理" v-loading="showLoading">
    <yu-xform related-table-name="refTable" form-type="search" v-model="searchFormdata">
      <yu-xform-group :column="4">
        <yu-xform-item label="方案名称" placeholder="方案名称" ctype="input" name="schemeName"></yu-xform-item>
        <yu-xform-item label="方案代码" placeholder="方案代码" ctype="input" name="schemeCode"></yu-xform-item>
		<yu-xform-item label="运行状态" placeholder="运行状态" ctype="select" name="runStateStr" :options="runStateStr"></yu-xform-item>
       <!-- <yu-xform-item label="有效标志" placeholder="有效标志" ctype="select" data-code="USE_SCHEME_VALID" name="validFlag"></yu-xform-item> -->
      </yu-xform-group>
    </yu-xform>
    <yu-toolBar>
      <yu-button-group>
        <yu-button @click="addFn" v-if="addFnShow">新增</yu-button>
        <yu-button @click="modifyFn" v-if="modifyFnShow">修改</yu-button>
        <yu-button @click="deleteFn" v-if="deleteFnShow">删除</yu-button>
      </yu-button-group>
      <yu-button-group>
        <yu-button @click="runFn" v-if="runFnShow">运行</yu-button>
        <yu-button @click="monitorFn" v-if="monitorFnShow">监控</yu-button>
      </yu-button-group>
    </yu-toolBar>
	<div ref="tableBox" style="overflow: auto;">
		<yu-xtable :height="tbHeight" ref="refTable" row-number :data-url="dataUrl" selection-type="checkbox" :pageable="true" max-height="550" @row-click="cellClick">
		  <yu-xtable-column label="重跑方案代码" prop="schemeCode" :show-overflow-tooltip="true"></yu-xtable-column>
		  <yu-xtable-column label="重跑方案名称" prop="schemeName" :show-overflow-tooltip="true"></yu-xtable-column>
		  <yu-xtable-column label="包含任务数量" prop="taskCount"></yu-xtable-column>
		  <yu-xtable-column label="包含作业数量" prop="actionCount"></yu-xtable-column>
		  <yu-xtable-column label="运行状态" prop="runState" :options="runState" ></yu-xtable-column>
		  <yu-xtable-column label="有效标志" prop="validFlag" data-code="USE_SCHEME_VALID">
			<template slot-scope="scope">
			  <yu-switch v-model="scope.row.validFlag" on-text="生效" off-text="失效" on-value="Y" off-value="N" :disabled="!modifyFnShow"
				@change="updateFlag(scope.row)"></yu-switch>
			</template>
		  </yu-xtable-column>
		</yu-xtable>
	</div>
  </yu-panel>
  <yu-xdialog :title="viewTitle" :visible.sync="updateDialog" width="1000px" v-loading="updateLoading">
    <yu-xform ref="updateForm" label-width="120px" v-model="updateFormData" label-width="140px">
      <yu-xform-group :column="3">
        <yu-xform-item label="方案代码" placeholder="方案代码" ctype="input" name="schemeCode" :rules="schemeCodeRules" :disabled="!isNew"></yu-xform-item>
        <yu-xform-item label="方案名称" placeholder="方案名称" ctype="input" name="schemeName" :rules="schemeNameRules" :disabled="!isNew"></yu-xform-item>
        <yu-xform-item label="有效标志" placeholder="有效标志" ctype="select" data-code="USE_SCHEME_VALID" rules="required" name="validFlag"></yu-xform-item>
      </yu-xform-group>
      <yu-xform-group :column="2">
        <yu-xform-item ctype="custom" label="周期时点" name="cycleTime">
          <template>
            <yu-date-picker v-model="cycleTime" type="daterange" start-placeholder="开始日期" end-placeholder="结束日期" value-format="yyyyMMdd"
              format="yyyyMMdd" @change="daterangeChange">
            </yu-date-picker>
          </template>
        </yu-xform-item>
        <div class="button-group" style="text-align: center">
          <el-button type="primary" @click="saveJobRedoPlan">保存</el-button>
          <el-button @click="updateDialog = false">取消</el-button>
          <el-button @click="taskSelect" type="primary">任务选择</el-button>
          <el-button @click="taskRemove">任务移除</el-button>
        </div>
      </yu-xform-group>
      <yu-xtable ref="refTaskTable" row-number :data="taskInfos" selection-type="checkbox" max-height="400">
        <yu-xtable-column label="应用系统" prop="appName" :show-overflow-tooltip="true"></yu-xtable-column>
        <yu-xtable-column label="任务名称" prop="taskName" :show-overflow-tooltip="true"></yu-xtable-column>
        <yu-xtable-column label="作业">
          <template slot-scope="scope">
            <yu-button size="small" @click="jobSelect(scope.row)">选择</yu-button>
			<yu-button size="small" @click="jobSelectOld(scope.row)">已选</yu-button>
          </template>
        </yu-xtable-column>
        <yu-xtable-column label="已选作业数" prop="actionCount"></yu-xtable-column>
        <yu-xtable-column label="关联" prop="validFlag" width="200px">
          <template slot-scope="scope">
            <!-- <yu-button size="small" @click="depjobSelect(scope.row)">上游</yu-button> -->
            <!-- <yu-button size="small" @click="triggerjobSelect(scope.row)">下游</yu-button> -->
			<yu-button size="small" @click="innerTriggerjobSelect(scope.row)">内部下游</yu-button>
			<yu-button size="small" @click="outerTriggerjobSelect(scope.row)">外部下游</yu-button>
          </template>
        </yu-xtable-column>
      </yu-xtable>
    </yu-xform>
  </yu-xdialog>
  <yu-xdialog title="任务选择" :visible.sync="taskChooseDialog" width="75%">
    <el-form-q ref="queryTaskForm" :field-data="taskFieldDatas" :buttons="taskButtons"></el-form-q>
    <el-table-x ref="taskTableRef" max-height="500" :data-url="taskDataUrl" :checkbox="true" :table-columns="taskFieldColumns"></el-table-x>
  </yu-xdialog>
  <yu-xdialog title="作业选择" :visible.sync="jobChooseDialog" width="75%">
    <el-form-q ref="queryJobForm" v-model="queryJobFormData" :field-data="jobFieldDatas" :buttons="jobButtons"></el-form-q>
    <yu-xtable ref="jobTableRef" row-number :data-url="jobDataUrl" selection-type="checkbox"  max-height="450" :default-load="false" :pageable="true" @loaded="jobListLoaded">
      <yu-xtable-column label="作业代码" prop="actionCode" :show-overflow-tooltip="true"></yu-xtable-column>
      <yu-xtable-column label="作业名称" prop="actionName" :show-overflow-tooltip="true"></yu-xtable-column>
      <yu-xtable-column label="是否运行" prop="runFlag">
        <template slot-scope="scope">
          <yu-switch v-model="scope.row.runFlag" on-text="Yes" off-text="No" on-value="Y" off-value="N" @change="chooseJob(scope.row)"></yu-switch>
        </template>
      </yu-xtable-column>
      <yu-xtable-column label="关联关系" prop="relation" data-code="USE_EVT_REL_TYPE"></yu-xtable-column>
      <yu-xtable-column label="关联作业代码" prop="relActionCode" :show-overflow-tooltip="true"></yu-xtable-column>
      <yu-xtable-column label="关联作业名称" prop="relActionName" :show-overflow-tooltip="true"></yu-xtable-column>
    </yu-xtable>
  </yu-xdialog>
  <yu-xdialog title="已选作业" :visible.sync="jobChooseDialogOld" width="75%">
	 <el-form-q ref="queryJobFormOld"   :buttons="jobButtonsOld"></el-form-q>
    <yu-xtable ref="jobTableRefOld" row-number selection-type="checkbox" :data="taskSelectedList" max-height="450" :pageable="false">
      <yu-xtable-column label="作业代码" prop="actionCode" :show-overflow-tooltip="true"></yu-xtable-column>
      <yu-xtable-column label="作业名称" prop="actionName" :show-overflow-tooltip="true"></yu-xtable-column>
      <yu-xtable-column label="是否运行" prop="runFlag">
        <template slot-scope="scope">
          <yu-switch v-model="scope.row.runFlag" on-text="Yes" off-text="No" on-value="Y" off-value="N" @change="chooseJobOld(scope.row)"></yu-switch>
        </template>
      </yu-xtable-column>
      <yu-xtable-column label="关联关系" prop="relation" data-code="USE_EVT_REL_TYPE"></yu-xtable-column>
      <yu-xtable-column label="关联作业代码" prop="relActionCode" :show-overflow-tooltip="true"></yu-xtable-column>
      <yu-xtable-column label="关联作业名称" prop="relActionName" :show-overflow-tooltip="true"></yu-xtable-column>
    </yu-xtable>
  </yu-xdialog>
  
  <yu-xdialog title="下游" :visible.sync="routerDialog" width="40%">
    <yu-xtable ref="routerTask" row-number  :data="routerList" max-height="450" :pageable="false">
      <yu-xtable-column label="任务名称" prop="taskName"></yu-xtable-column>
      <yu-xtable-column label="新增作业数量" prop="count"></yu-xtable-column>
    </yu-xtable>
  </yu-xdialog>
</div>
<style type="text/css">
	.bth-group{
		min-width: 300px;
	}
</style>